﻿@using SCMS.Resource
@model SCMS.Model.PaymentVoucher
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>
            @Resources_morgan.PaymentVoucher_ViewPVDetails_PVNo .:: @Model.RefNumber</h3>
    </div>
    @if (Model.CanEdit)
    {
        <center>
            @Ajax.ActionLink(Resources_morgan.PaymentVoucher_ViewPVDetails_EditPV, "EditPVDetais", new { PVId = Model.Id }, new AjaxOptions
            {
                OnBegin = string.Format("ShowDialogue('{0}')", Resources_morgan.PaymentVoucher_ViewPVDetails_EditPV),
                UpdateTargetId = "popup-page",
                LoadingElementId = "popup-loading",
                OnSuccess = "CenterPopup"
            }) |
            @Ajax.ActionLink(Resources_morgan.PaymentVoucher_ViewPVDetails_DeletePV, "DeletePV", new { PVId = Model.Id }, new AjaxOptions
            {
                UpdateTargetId = "pvDiv",
                LoadingElementId = "loading",
                Confirm = string.Format(Resources.Global_String_ConfirmDelete, Model.RefNumber),
                OnSuccess = "usermsg('" + Resources.OrderRequest_String_SuccessMsg + "');if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
            })
        </center>
    }
    else
    {
        <br />
    }
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th align="center">
                @Resources_morgan.Global_String_VoucherNumber
            </th>
            <th align="center">
                @Resources.Budget_CreateProject_ProjectName
            </th>
            <th align="center">
                @Resources.Budget_CreateProject_ProjectNumber
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.RefNumber
            </td>
            <td align="center">
                @Model.PaymentRequest.PurchaseOrder.ProjectDonor.Project.ShortName
            </td>
            <td align="center">
                @Model.PaymentRequest.PurchaseOrder.ProjectDonor.ProjectNumber
            </td>
        </tr>
        <tr class="gridheader">
            <th align="center">
                @Resources.Global_String_Date:
            </th>
            <th align="center">
                @Resources_morgan.Global_String_RequestforPaymentNumber
            </th>
            <th align="center">
                @Resources.Global_String_PONo
            </th>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Model.PreparedOn.Value.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.PaymentRequest.RefNumber
            </td>
            <td align="center">
                @Model.PaymentRequest.PurchaseOrder.RefNumber
            </td>
        </tr>
        <tr class="gridheader">
            <th align="left" colspan="3">
                @Resources_morgan.Global_String_ModeofPayment
            </th>
        </tr>
        <tr class="gridodd">
            <td align="left" colspan="3">
                @Model.PaymentRequest.PaymentType.Description
            </td>
        </tr>
        <tr class="gridodd">
            <td align="center">
                @Resources_morgan.PaymentVoucherLoadPV_ProjectBankAccount
            </td>
            <td align="center" colspan="2">
                @Model.ProjectBankAccount
            </td>
        </tr>
    </table>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <th>
                @Resources.Global_String_BL
            </th>
            <th>
                @Resources.Global_String_PaymentDetails
            </th>
            <th>
                @Resources.ExpenseClaim_ViewExpsClaimsDetails_AccountCode
            </th>
            <th>
                @Resources.Global_String_Amount
            </th>
        </tr>
        @foreach (var item in Model.PaymentVoucherBudgetLines)
        {
            <tr class="gridodd">
                <td style="width: 15%; text-align: left;" title="@item.PaymentRequestBudgetLine.ProjectBudget.Description">
                    @item.PaymentRequestBudgetLine.ProjectBudget.LineNumber
                </td>
                <td style="width: 50%; text-align: left;">
                    @item.Description
                </td>
                <td style="width: 17%; text-align: left;" title="@item.GeneralLedger.Description">
                    @item.GeneralLedger.Code
                </td>
                <td style="width: 17%; text-align: right;">
                    @item.Amount.Value.ToString("##,##0.00")
                </td>
            </tr>
        }
        <tr>
            <td class="gridheader" colspan="3" align="right">
                <strong>@Resources.Global_String_TotalAmount:</strong>
            </td>
            <td align="right" colspan="5">
                @Model.TotalAmount.Value.ToString("##,##0.00")
            </td>
        </tr>
    </table>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr>
            <td style="width: 20%;">
                @Resources_morgan.PaymentVoucher_ViewPVDetails_AmountinWords:
            </td>
            <td>
                @Model.AmountInWords
            </td>
        </tr>
        <tr>
            <td>
                @Resources.Request4Advance_CreateRFA_PaymentTo (@Resources_morgan.PaymentVoucher_ViewPVDetails_SupplierName):
            </td>
            <td>
                @Model.PaymentRequest.Supplier.Name
            </td>
        </tr>
    </table>
    <br />
    <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
        <tr class="gridheader">
            <td width="20%">
                @Resources_morgan.Gloabl_String_Authorization
            </td>
            <td width="27%">
                @Resources.Global_String_PreparedBy
            </td>
            <td width="27%">
                @Resources.Global_String_AuthorizedBy
            </td>
            <td width="26%">
                @Resources.Global_String_ReceivedBy
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources.Global_String_Name:
            </td>
            <td>
                @Model.PreparedByStaff.StaffName
            </td>
            <td>
                @if (Model.AuthourisedByStaff != null)
                { 
                    @Model.AuthourisedByStaff.StaffName
                }
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources.Global_String_Title:
            </td>
            <td>
                @Model.PreparedByStaff.Designation
            </td>
            <td>
                @if (Model.AuthourisedByStaff != null)
                { 
                    @Model.AuthourisedByStaff.Designation
                }
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources.Global_String_Date:
            </td>
            <td>
                @Model.PreparedOn.Value.ToString("dd/MM/yyyy h:mm tt")
            </td>
            <td>
                @if (Model.AuthorizedOn != null)
                { 
                    @Model.AuthorizedOn.Value.ToString("dd/MM/yyyy h:mm tt")
                }
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td class="gridheader">
                @Resources.Global_String_Signature:
            </td>
            <td>
                @if (Model.PreparedByStaff.SignatureImage != null)
                { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.PreparedByStaff.PersonID, area = "" })" alt="" style="max-width: 100px;" />
                }
            </td>
            <td>
                @if (Model.AuthorizedBy != null && Model.AuthourisedByStaff.SignatureImage != null)
                { 
                    <img src="@Url.Action("Photo", "Person", new { id = Model.AuthourisedByStaff.PersonID, area = "" })" alt="" style="max-width: 100px;" />
                }
            </td>
            <td>
            </td>
        </tr>
    </table>
    <hr />
    @if (Model.IsSubmitted == true)
    {
        <a class="btn btn-primary" target="_blank" href="/Reports/PVoucher/Index?PVId=@Model.Id"  style="margin-left: 48%; margin-bottom: 2%;">
            @Resources.Budget_ViewBudget_DownloadPdf
        </a>
    }
</div>
<br />
<p>
    @Ajax.ActionLink(Resources.Global_String_BackToList, "Index", new AjaxOptions
    {
        UpdateTargetId = "pvDiv",
        LoadingElementId = "loading",
        Url = Url.Action("ViewPV"),
        OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
    })
</p>
